package largemodel

import (
	"context"
	"github.com/jinzhu/copier"
	model "large-model-platform-backend/mongo"

	"large-model-platform-backend/internal/svc"
	"large-model-platform-backend/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type AddKiMiLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewAddKiMiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddKiMiLogic {
	return &AddKiMiLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *AddKiMiLogic) AddKiMi(req *types.LargeModelAddKiMiReq) (resp *types.BooleanResp, err error) {
	model1 := l.svcCtx.LargeModel
	mi := req.KiMi
	kiMi := model.IKiMi{}
	copier.Copy(&kiMi, &mi)
	err = model1.UpdateKiMi(l.ctx, req.ID, kiMi)
	if err != nil {
		return nil, err
	}

	return &types.BooleanResp{
		Result: types.Result{
			Code: 200,
		},
		Data: true,
	}, nil
}
